package com.jcl.recruit.elasticsearch.resume.logic;

import com.jcl.core.utils.CollectionUtils;
import com.jcl.recruit.elasticsearch.resume.dao.SearchResumeJobIntentionDao;
import com.jcl.recruit.elasticsearch.resume.model.SearchResumeJobIntention;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @ClassName SearchResumeJobIntentionLogic
 * @Author yyliu
 * @Date 2018/11/17 11:51
 * @Version 1.0
 **/
@Component
public class SearchResumeJobIntentionLogic {

    @Autowired
    private SearchResumeJobIntentionDao searchResumeJobIntentionDao;

    public Map<Integer, SearchResumeJobIntention> findEntityMapByResumeIds(List<Integer> resumeIds) {
        Map<Integer, SearchResumeJobIntention> dataMap = new HashMap<>();
        List<SearchResumeJobIntention> list = searchResumeJobIntentionDao.findListByResumeIds(resumeIds);
        if (CollectionUtils.isNotEmpty(list)) {
            for (SearchResumeJobIntention entity : list) {
                dataMap.put(entity.getResumeId(), entity);
            }
        }

        return dataMap;
    }

    public List<SearchResumeJobIntention> findListByResumeIds(List<Integer> resumeIds) {
        return searchResumeJobIntentionDao.findListByResumeIds(resumeIds);
    }

    public Map<String, Object> findOneMap(Integer resumeId) {
        return searchResumeJobIntentionDao.findOneMap(resumeId);
    }

    public SearchResumeJobIntention findOne(Integer resumeId) {
        return searchResumeJobIntentionDao.findOne(resumeId);
    }

    public int add(SearchResumeJobIntention entity) {
        return searchResumeJobIntentionDao.add(entity);
    }

    public int batchDeleteByResumeIds(List<Integer> resumeIds) {
        return searchResumeJobIntentionDao.batchDeleteByResumeIds(resumeIds);
    }
}
